<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    /*
    * 实现一个函数：输入 数字0-9 输出中文 零-九
    *
    *
    *
    * */

    //错误版本
    function change(num){
        switch(num){
            case 0:
                return "零";
                break
            case 1:
                return "一";
                break
            case 2:
                return "二";
                break
            case 3:
                return "三";
                break
            case 4:
                return "4";
                break
            case 5:
                return "五";
                break
            case 6:
                return "六";
                break
            case 7:
                return "七";
                break
            case 8:
                return "八";
                break
            case 9:
                return "九";
                break
        }
    }

    //优化版本：输入有哪些情况 0-9 这十种情况 并且输出也是 零-九这十种情况 可以联想用数组和下标来解决
    //假设有一个答案参考表 用户每次输入 都可以查询这个答案表 输出相应结果

    function chang2(num){
        let changeMap = ["零","一","二","三","四","五","六","七","八","九"]
        return changeMap[num]
    }



</script>
</body>
</html>